package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursePlanDto;
import com.zzyl.dto.NursePlanProjectDto;
import com.zzyl.entity.NursePlan;
import com.zzyl.entity.NursePlanProject;
import com.zzyl.service.NursePlanService;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursePlanProjectVo;
import com.zzyl.vo.NursePlanVo;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class NursePlanController extends BaseController{

    @Autowired
    private NursePlanService nursePlanService;
    @Autowired
    private NursingProjectService nursingProjectService;



    /**
     * 护理计划-新增计划
     */
    @PostMapping
    public ResponseResult insertNursePlan(@RequestBody NursePlanDto dto){
            nursePlanService.insert(dto);
            return success();
    }

    /**
     * 护理计划-分页查询
     */
    @GetMapping("/nursing/plan/search")
    public ResponseResult<PageResponse<NursePlanVo>> selectByPage(@RequestParam(name = "name",required = false) String name,
                                                    @RequestParam(name = "pageNum",defaultValue = "1") Integer pageNum,
                                                    @RequestParam(name = "pageSize",defaultValue = "10") Integer pageSize,
                                                    @RequestParam(name = "status",required = false) Integer status){
        PageResponse<NursePlanVo> page = nursePlanService.selectByPage(name,pageNum,pageSize,status);
        return success(page);
    }

    /**
     * 护理计划-根据id查询
     */
    @GetMapping("/nursing/plan/{id}")
    public ResponseResult<NursePlanVo> selectById(@PathVariable("id")Long id){
        NursePlanVo planProjectVo = nursePlanService.selectById(id);
        return success(planProjectVo);
    }

    /**
     * 护理计划-修改
     */
    @PutMapping("/nursing/plan/{id}")
    public ResponseResult update(@RequestBody NursePlanDto dto){
        nursePlanService.update(dto);
        return success();
    }

    /**
     * 护理计划-删除
     */
    @DeleteMapping("/nursing/plan/{id}")
    public ResponseResult delete(@PathVariable("id") Long id){
        nursePlanService.delete(id);
        return success();
    }

    /**
     * 护理计划-启用 禁用 0-禁用 1-启用
     */
    @PutMapping("nursing/{id}/status/{status}")
    public ResponseResult choiceUpdate(@PathVariable("id") Long id,
                                        @PathVariable("status") Integer status){

        nursePlanService.choiceUpdate(id,status);
        return success();
    }

}
